<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/jsp/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>信息编辑窗体</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/plugins/h+/css/plugins/webuploader/webuploader.css">
    <link href="${ctxStatic}/plugins/h+/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/js/plugins/fancybox/jquery.fancybox.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <style>
        .jstree-open>.jstree-anchor>.fa-folder:before{content:"\f07c"}.jstree-default .jstree-icon.none{width:0}
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">

                <div class="ibox-content">
                    <form onsubmit="return  false" class="form-horizontal m-t" id="bizpersonForm">
                        <input id="code" value="${bizperson.code}" name="code" type="hidden">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">姓名：</label>
                            <div class="col-sm-8">
                                <input id="person_name" value="${bizperson.person_name}" name="person_name" class="form-control" type="text">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">电话：</label>
                            <div class="col-sm-8">
                                <input id="phone" value="${bizperson.phone}" name="phone" class="form-control" type="text" >
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">工号：</label>
                            <div class="col-sm-8">
                                <input id="number" value="${bizperson.number}" name="number" class="form-control" type="text">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">送券金额：</label>
                            <div class="col-sm-8">
                                <select class="form-control m-b" name="couponsMoney" >
                                    <c:choose>
                                        <c:when test="${bizperson.couponsMoney=='0'}">
                                            <option value="0" selected="selected">0元券</option>
                                            <option value="100">100元券</option>
                                        </c:when>
                                        <c:when test="${bizperson.couponsMoney=='10000'}">
                                            <option value="0" >0元券</option>
                                            <option value="100" selected="selected">100元券</option>
                                        </c:when>
                                        <c:otherwise>
                                            <option value="0" >0元券</option>
                                            <option value="100" >100元券</option>
                                        </c:otherwise>
                                    </c:choose>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">备注：</label>
                            <div class="col-sm-8">
                                <textarea id="notes" name="notes" class="form-control">${bizperson.notes}</textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <input type="submit" class="btn btn-primary" value="提交" >
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="${ctxStatic}/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
<script src="${ctxStatic}/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/bootstrap-table.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/locale/bootstrap-table-zh-CN.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/export/bootstrap-table-export.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/editable/bootstrap-table-editable.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/content.min.js?v=1.0.0"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/layer/laydate/laydate.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/validate/jquery.validate.min.js"></script>

<script>

    var areaData;
    var index = parent.layer.getFrameIndex(window.name);
    $(function(){
        $("#bizpersonForm").validate({
            submitHandler : function() {
                doSubmit();
            },
            rules:{
                person_name:{
                    required:true,
                    maxlength:50
                },
                phone:{
                    required:true,
                    checkPhone:true
                },
                number:{
                    required:true,
                    maxlength:50
                },
                notes:{
                    required:false,
                    maxlength:200
                }

            },
            messages:{
                person_name:{
                    required:"*必填！",
                    maxlength:"*长度不能超过50位！"
                },
                phone:{
                    required:"*必填！"
                },
                number:{
                    required:"*必填！",
                    maxlength:"*长度不能超过50位！"
                },
                notes:{
                    required:"*必填！",
                    maxlength:"*长度不能超过200位！"
                }
            },
            //是否在获取焦点时验证
            onfocusout:true,
            //是否在敲击键盘时验证
            //onkeyup:false,
            //提交表单后，（第一个）未通过验证的表单获得焦点
            focusInvalid:false,
            //当未通过验证的元素获得焦点时，移除错误提示
            focusCleanup:false
        });

        //自定义正则表达示验证方法
        $.validator.addMethod("checkPhone",function(value,element,params){
            var checkPhone = /^1[3,5,7,8]\d{9}$/;
            return this.optional(element)||(checkPhone.test(value));
        },"*请输入正确的手机号码！");

    });


    function doSubmit()
    {
        $.ajax( {
            url:'${pageContext.request.contextPath}/bizperson/doSave.ac',// 跳转到 action
            data:$("#bizpersonForm").serialize(),
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data.success==true) {
                    alert("操作成功！");

                    parent.layer.close(index);
                }else {
                    alert("操作失败!");
                }
            },
            error : function() {
                alert("操作失败！");
            }
        });
    }
</script>

</body>

</html>

